/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.uhk.ppro.response.web;

import cz.uhk.ppro.response.model.Course;
import cz.uhk.ppro.response.model.Student;
import cz.uhk.ppro.response.model.Test;
import cz.uhk.ppro.response.service.DatabaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author Insidel
 */

@Controller
public class CourseStatisticsController {

    @Autowired
    private DatabaseService databaseSession;

    @RequestMapping("/teststatistics.do")
    public ModelAndView zobrazitStatistikyStestu(@RequestParam("id_test") int id_test, @RequestParam("id_course") int id_course)
    {
        ModelAndView model = new ModelAndView("testStatistics");

        Test t = databaseSession.getTestById(id_test);
        Course c = databaseSession.getCourseById(id_course);

        model.addObject("testik", t);
        model.addObject("kurzy", databaseSession.getCoursesAndTests(c, t));

        return model;
    }

    @RequestMapping("/studentstatistics.do")
    public ModelAndView zobrazitStatistikyStudetna(@RequestParam("id_student") int id_student, @RequestParam("id_course") int id_course)
    {
        ModelAndView model = new ModelAndView("studentStatistics");

        Student s = databaseSession.getStudentById(id_student);
        Course c = databaseSession.getCourseById(id_course);
        model.addObject("studentik", s);
        model.addObject("kurzy", databaseSession.getCoursesAndStudents(c, s));

        return model;
    }

}
